Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

294
Vistas
I am having a problem with v-if in a nested loop [vuejs]

My problem is I am trying to edit a role so I have two functions, one to bring back the role and its permissions and one to bring all permissions. I am trying to do a nested v-for loop to show all permissions and check the one that was already selected. everything works fine but I can't show all permissions for some reason. There is one more permission called "Delete user" that doesn't show up. anyway, the problem is 100% from the template side.

 <div class="container" v-for="(mission,key,index) in permissions" :key="key">
    <div class="form-group" v-for="(per,key,index) in selected" :key="key" v-if="mission.id == per.id">
        <input type="checkbox"  v-model="mission[key]"  checked >{{mission.name}}
        <div v-if="mission.id !== per.id">
        <input type="checkbox"  v-model="mission[key]">{{mission.name}}
        <p>fucking hell</p>
      </div>
   </div>                      
</div>
                    
<script>
export default {
    data(){
        return{
            role:'',
            permissions:[],
            selected:[],
        }
    },
    mounted(){
        this.showRole()
        this.getPermissions()
        
    },
    methods:{
        showRole(){
           
            this.axios.get(`/api/role/${this.$route.params.id}`).then(response=>{
                const{role ,selected}= response.data
                this.role= role
                this.selected = selected
            }).catch(error=>{
                console.log(error)
            })
        },
        getPermissions(){
            this.axios.get('/api/permissions').then(response=>{
                this.permissions =response.data
            }).catch(error=>{
                console.log(error)
            })
        },
    }
}
</script>

here is a picture of the API that returns all permission. you can see delete user is there at the end.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Using v-if and v-for together is not recommended. Look at style guide for more info.

When used together with v-if, v-for has a higher priority than v-if.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda